package org.dhbw.jee.business.db;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

/**
 * The persistent class for the album database table.
 * 
 */
@Entity(name = "ALBUM")
@NamedQueries({ @NamedQuery(name = Album.GETALL, query = "SELECT a FROM ALBUM a") })
public class Album implements Serializable {
	private static final long serialVersionUID = 1L;

	public static final String GETALL = "Album.findAll";

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "ID")
	private int id;

	@Column(name = "IMAGE")
	private String image;

	@Column(name = "NAME")
	private String name;

	@Column(name = "RATING")
	private int rating;

	@ManyToOne(fetch = FetchType.EAGER)
	private Interpret interpret;

	@ManyToMany(mappedBy = "albums", fetch = FetchType.LAZY)
	private List<User> users;

	public Album() {
		super();
	}

	public Album(String image, String name, Interpret interpret) {
		super();
		this.image = image;
		this.name = name;
		this.interpret = interpret;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Interpret getInterpret() {
		return this.interpret;
	}

	public void setInterpret(Interpret interpret) {
		this.interpret = interpret;
	}

	public List<User> getUsers() {
		return this.users;
	}

	public void setUsers(List<User> users) {
		this.users = users;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public int getId() {
		return id;
	}

	public int getRating() {
		return rating;
	}

	public void setRating(int rating) {
		this.rating = rating;
	}

	@Override
	public String toString() {
		return new StringBuilder().append("Album (").append(id).append(", ").append(name).append(", ").append(interpret).append(")").toString();
	}

}